<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浏览器-JS引擎执行任务的机制案例2</title>
</head>

<body>
    <button id="button">触发Click事件</button>
    <script>
        const _button = document.querySelector('#button')
        _button.addEventListener('click', () => {
            Promise.resolve().then(() => {
                console.log('任务1')
            })
            console.log('任务2')
        })
        _button.addEventListener('click', () => {
            Promise.resolve().then(() => {
                console.log('任务3')
            })
            console.log('任务4')
        })
        console.log([_button])
        _button.click()
    </script>
</body>

</html>